from typing import List


class Solution:
    def minTime(self, skill: List[int], mana: List[int]) -> int:
        n = len(skill)
        m = len(mana)
        times = [0] * n
        for i in range(m):
            for j in range(n):
                if j:
                    times[j] = max(times[j],times[j-1])+skill[i]*mana[j]
                if i:
